import { GraphQLError } from 'graphql'

import type { QueryResolvers } from "./../../../types.generated";
export const book: NonNullable<QueryResolvers['book']> = async (
  _parent,
  _arg,
  _ctx
) => {
  if (!_ctx.jwt) {
    // No JWT token provided, we are not authenticated
    throw new GraphQLError('Required token.')
  }
  console.log("sub:", _ctx.jwt.sub);

  return {
    id: _ctx.jwt.sub,
    fullName: "J. R. R. Tolkien",
    isAdmin: true,
    isbn: "",
  };
};
